#include <string>
#include <boost/program_options.hpp>

#include "vigilante.h"
#include "mvc.h"
#include "views/sdl/sdlview.h"
#include "views/gtk/gtkview.h"
#include "views/clutter/clutterview.h"

using namespace std;
namespace po = boost::program_options;

Vigilante::Vigilante(int argc, char **argv) {
    Controller *c = new Controller();

    try {
        po::options_description desc("Allowed options");
        desc.add_options()
                ("help", "produce help message")
                ("view,v", po::value<string > (), "choose view: gtk, sdl or clutter.")
                ;

        po::variables_map vm;
        po::store(po::parse_command_line(argc, argv, desc), vm);
        po::notify(vm);
        
        if (vm.count("help")) {
            cout << desc << "\n";
            return;
        }
        
        if (vm.count("view")) {
            if (vm["view"].as<string > () == "gtk") {
                GtkView gtkview(c);
            } else if (vm["view"].as<string > () == "sdl") {
                SDLView sdlview(c);
            } else if (vm["view"].as<string > () == "clutter") {
                ClutterView clutterview(c);
            } else {
                cout << "View can be gtk OR sdl." << endl;
            }
        } else {
            cout << "You have to choose a view." << endl;
        }
    } catch (exception& e) {
        cerr << "error: " << e.what() << "\n";
        return;
    } catch (...) {
        cerr << "Exception of unknown type!\n";
    }
}

int main(int argc, char **argv) {
    Vigilante Vigilante(argc, argv);
    return 0;
}
